package cn.iocoder.yudao.module.biz.dal.mysql.expand.record;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.biz.controller.admin.expand.record.vo.*;
import cn.iocoder.yudao.module.biz.dal.dataobject.expand.record.ExpandRecordDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 拓展记录 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ExpandRecordMapper extends BaseMapperX<ExpandRecordDO> {

    default PageResult<ExpandRecordDO> selectPage(ExpandRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ExpandRecordDO>()
                .eqIfPresent(ExpandRecordDO::getInterviewee, reqVO.getInterviewee())
                .eqIfPresent(ExpandRecordDO::getIntervieweePhone, reqVO.getIntervieweePhone())
                .eqIfPresent(ExpandRecordDO::getIntervieweePosition, reqVO.getIntervieweePosition())
                .eqIfPresent(ExpandRecordDO::getCustomerRequire, reqVO.getCustomerRequire())
                .eqIfPresent(ExpandRecordDO::getBreakthroughPoint, reqVO.getBreakthroughPoint())
                .betweenIfPresent(ExpandRecordDO::getExpandTime, reqVO.getExpandTime())
                .eqIfPresent(ExpandRecordDO::getBusinessType, reqVO.getBusinessType())
                .eqIfPresent(ExpandRecordDO::getValueAddService, reqVO.getValueAddService())
                .eqIfPresent(ExpandRecordDO::getExpandProcess, reqVO.getExpandProcess())
                .eqIfPresent(ExpandRecordDO::getExpandSituation, reqVO.getExpandSituation())
                .eqIfPresent(ExpandRecordDO::getCustomerType, reqVO.getCustomerType())
                .eqIfPresent(ExpandRecordDO::getCustomerLevel, reqVO.getCustomerLevel())
                .eqIfPresent(ExpandRecordDO::getNextTimeVisit, reqVO.getNextTimeVisit())
                .eqIfPresent(ExpandRecordDO::getScenePictureUrl, reqVO.getScenePictureUrl())
                .eqIfPresent(ExpandRecordDO::getSecurityReportUrl, reqVO.getSecurityReportUrl())
                .eqIfPresent(ExpandRecordDO::getServiceSchemeUrl, reqVO.getServiceSchemeUrl())
                .betweenIfPresent(ExpandRecordDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ExpandRecordDO::getOwnerUserId, reqVO.getOwnerUserId())
                .eqIfPresent(ExpandRecordDO::getTargetName, reqVO.getTargetName())
                .orderByDesc(ExpandRecordDO::getId));
    }


    List<ExpandRecordDO> selectListByInterviewee(ExpandRecordPageReqVO reqVO);

    List<ExpandRecordDO> selectListByCondition(ExpandRecordPageReqVO reqVO);

    ExpandRecordCountRespVO countByType(ExpandRecordCountReqVO reqVO);

    ExpandRecordCountRespVO countSum( Long id);

    ExpandRecordCountRespVO countSumByIdAndMonth( @Param("id")Long id,@Param("month") String month);

    List<ExpandRecordRespVO> getExpandRecordCurrent( @Param("id")Long id,@Param("month") String month);

    Map<String,Object> getExpandRecordGk( @Param("tenantId")Long tenantId);

    List<ExpandRecordCheckRespVo> checkRecordByCustomerName(@Param("customerName") String customerName);

}